import PropTypes from 'prop-types'

const AboutChilden = ({ count, onCount }) => {
    const setCount = (count) => {
        onCount(count)
    }

    return (
        <div className="aboutChild">
            从子组件更改父组件的值
            <h1>
                {count}
            </h1>
            <div>
                <button style={{ marginRight: '10px' }} className="btn btn-primary" onClick={() => setCount(count + 1)}>增加</button>
                <button className="btn btn-primary" onClick={() => setCount(count - 1)}>减少</button>
            </div>
        </div>
    )
}

// 添加 PropTypes 校验
AboutChilden.propTypes = {
    count: PropTypes.number,        // 数字类型，非必填
    onCount: PropTypes.func        // 函数类型，非必填
}

export default AboutChilden
